<template>
  <div class="header">
    <p>我是header</p>
    <p>count的值为{{ count1 }}</p>
    <p>价格为{{ price1 }}</p>
    <button @click="increment">累加</button>
    <button @click="incrementN({ n: 3 })">累加n</button>
  </div>
</template>

<script>
import { mapMutations, mapState } from "vuex";
export default {
  name: "Header",
  computed: {
    // mapState的对象写法
    ...mapState({ count1: "count", price1: "price" }),
  },
  methods: {
    ...mapMutations(["increment", "incrementN"]),
  },
};
</script>

<style scoped>
.header {
  margin: 30px;
  background: palevioletred;
}
</style>